using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class forums_controls_forums_forumgrid : Controls.DataManagerForumControl
{
    protected override void ItemChanged()
    {
        SetDataSource(DAL.Forums.GetByParent(CurrentForum));
    }

    public void SetDataSource(List<DAL.Forum> forums)
    {
        gridForums.DataSource = forums;
        gridForums.DataBind();

        GridHasItems = (forums.Count > 0);
    }

    protected DAL.Thread GetLastThread(DAL.Forum forum)
    {
        if (forum != null)
        {
            return forum.GetLastThread();
        }
        else
        {
            return null;
        }
    }

    public bool GridHasItems
    {
        get
        {
            if (ViewState["GridHasItems"] != null)
            {
                return Convert.ToBoolean(ViewState["GridHasItems"]);
            }
            else
            {
                return false;
            }
        }
        set
        {
            ViewState["GridHasItems"] = value;
        }
    }

    public bool ShowHeader
    {
        get
        {
            if (ViewState["ShowHeader"] != null)
            {
                return (bool)ViewState["ShowHeader"];
            }
            return false;
        }
        set
        {
            ViewState["ShowHeader"] = value;
        }
    }
}
